import React, { useEffect, useState } from 'react'
import { View  } from "@tarojs/components";
import { Picker, Cell } from '@nutui/nutui-react-taro'
import { getAddr } from '../../api/user'
import addressJson from './address.js'
import './index.scss'

const address_picker = (props) => {
  const { isVisible } = props
  const [customCityData, setCustomCityData] = useState(addressJson.addressJSON)
  
  const setChooseValueCustom = (
    options,
    values
  ) => {
    // const str = options.map((item) => item.text).join('-')
    props.getAddress(options)
  }
  return (
    <View className="pickerWrap">
      <Picker
        visible={isVisible}
        options={customCityData}
        closeOnOverlayClick={false}
        title='请选择常住地址'
        
        onCancel={()=>props?.onCancel()}
        onClose={() => {
          
          // setIsVisible(false)
          props.changeVisibel()
        }}
        onConfirm={(list, values) => setChooseValueCustom(list, values)}
        onChange={(options, value, columnIndex) => {
          // console.log(asyncData, '多级联动', columnIndex, value, options)
        }}
      />
    </View>
  )
}
export default address_picker
